<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TemplateArticulatedSimulink</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] },
  TeX: { equationNumbers: { autoNumber: 'all' } }
});
</script>
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
body > * {
  max-width: 1000px;
}
body {
  font-family: "Roboto Condensed", sans-serif;
  padding-left: 7.5em;
  padding-right: 7.5em;
}
pre, code {
  max-width: 60em;
  font-family: monospace;
}
pre.oct-code {
  border: 1px solid Grey;
  padding: 5px;
}
pre.oct-code-output {
  margin-left: 2em;
}
span.comment {
  color: ForestGreen;
}
span.keyword {
  color: Blue;
}
span.string {
  color: DarkOrchid;
}
footer {
  margin-top: 2em;
  font-size: 80%;
}
a, a:visited {
  color: Blue;
}
h2 {
  font-family: "Roboto Condensed", serif;
  margin-top: 1.5em;
}
h2 a, h2 a:visited {
  color: Black;
}
</style>
</head>
<body>
<p><b>Running the Simulink model</b></p><pre class="oct-code">sim(<span class="string">'ArticulatedVehicleSimulink'</span>);</pre><p>Each vehicle state variable goes to a scope. And the output of the model is saved in workspace.</p><p><b>Results</b></p><p>To generate the graphics the same model used in <a href="ArticulatedVehicleSFunction.html">ArticulatedVehicleSFunction.m</a> must be defined.</p><pre class="oct-code"><span class="comment">% Choosing tire model</span>
TireModel = VehicleDynamicsLateral.TirePacejka();
<span class="comment">% Defining tire parameters</span>
TireModel.a0 = 1;
TireModel.a1 = 2;
TireModel.a2 = 700;
TireModel.a3 = 5000;
TireModel.a4 = 80;
TireModel.a5 = 0;
TireModel.a6 = 0;
TireModel.a7 = 0.6;
TireModel.a8 = 0;
TireModel.a9 = 0;
TireModel.a10 = 0;
TireModel.a11 = 0;
TireModel.a12 = 0;
TireModel.a13 = 0;

<span class="comment">% Choosing vehicle model</span>
VehicleModel = VehicleDynamicsLateral.VehicleArticulatedNonlinear();
<span class="comment">% Defining vehicle parameters</span>
VehicleModel.mF0 = 5200;
VehicleModel.mR0 = 2400;
VehicleModel.mF = 6000;
VehicleModel.mR = 10000;
VehicleModel.mM = 17000;
VehicleModel.IT = 46000;
VehicleModel.IS = 450000;
VehicleModel.lT = 3.5;
VehicleModel.lS = 7.7;
VehicleModel.c = -0.3;
VehicleModel.nF = 2;
VehicleModel.nR = 4;
VehicleModel.nM = 8;
VehicleModel.wT = 2.6;
VehicleModel.wS = 2.4;
VehicleModel.muy = 0.8;
VehicleModel.deltaf = 0;
VehicleModel.Fxf = 0;
VehicleModel.Fxr = 0;
VehicleModel.Fxm = 0;
VehicleModel.tire = TireModel;

simulator = VehicleDynamicsLateral.Simulator(VehicleModel, tout);

<span class="comment">% Retrieving states from Simulink model</span>
simulator.XT = simout.Data(:,1);
simulator.YT = simout.Data(:,2);
simulator.PSI = simout.Data(:,3);
simulator.PHI = simout.Data(:,4);
simulator.VEL = simout.Data(:,5);
simulator.ALPHAT = simout.Data(:,6);
simulator.dPSI = simout.Data(:,7);
simulator.dPHI = simout.Data(:,8);

g = VehicleDynamicsLateral.Graphics(simulator);
g.TractorColor = <span class="string">'r'</span>;

g.Frame();</pre><img width="800" src="../illustrations/frame/TemplateArticulatedSimulinkFrame.png" alt="../illustrations/frame/TemplateArticulatedSimulinkFrame.png"><pre class="oct-code">g.Animation();</pre><p>As expected the vehicle starts traveling in a straight line and starts a turn at \(t = 1 \, s\) because of the step function.</p><img src="../illustrations/AnimationTemplateArticulatedSimulink.gif" alt="../illustrations/AnimationTemplateArticulatedSimulink.gif">
<footer><hr><a href="http://www.octave.org">Published with GNU Octave 4.2.1</a></footer>
<!--
##### SOURCE BEGIN #####
%%
% *Running the Simulink model*
%

sim('ArticulatedVehicleSimulink');

%%
% Each vehicle state variable goes to a scope. And the output of the model is saved in workspace.
%
%%
% *Results*
%
% To generate the graphics the same model used in <ArticulatedVehicleSFunction.html ArticulatedVehicleSFunction.m> must be defined.

% Choosing tire model
TireModel = VehicleDynamicsLateral.TirePacejka();
% Defining tire parameters
TireModel.a0 = 1;
TireModel.a1 = 2;
TireModel.a2 = 700;
TireModel.a3 = 5000;
TireModel.a4 = 80;
TireModel.a5 = 0;
TireModel.a6 = 0;
TireModel.a7 = 0.6;
TireModel.a8 = 0;
TireModel.a9 = 0;
TireModel.a10 = 0;
TireModel.a11 = 0;
TireModel.a12 = 0;
TireModel.a13 = 0;

% Choosing vehicle model
VehicleModel = VehicleDynamicsLateral.VehicleArticulatedNonlinear();
% Defining vehicle parameters
VehicleModel.mF0 = 5200;
VehicleModel.mR0 = 2400;
VehicleModel.mF = 6000;
VehicleModel.mR = 10000;
VehicleModel.mM = 17000;
VehicleModel.IT = 46000;
VehicleModel.IS = 450000;
VehicleModel.lT = 3.5;
VehicleModel.lS = 7.7;
VehicleModel.c = -0.3;
VehicleModel.nF = 2;
VehicleModel.nR = 4;
VehicleModel.nM = 8;
VehicleModel.wT = 2.6;
VehicleModel.wS = 2.4;
VehicleModel.muy = 0.8;
VehicleModel.deltaf = 0;
VehicleModel.Fxf = 0;
VehicleModel.Fxr = 0;
VehicleModel.Fxm = 0;
VehicleModel.tire = TireModel;

simulator = VehicleDynamicsLateral.Simulator(VehicleModel, tout);

% Retrieving states from Simulink model
simulator.XT = simout.Data(:,1);
simulator.YT = simout.Data(:,2);
simulator.PSI = simout.Data(:,3);
simulator.PHI = simout.Data(:,4);
simulator.VEL = simout.Data(:,5);
simulator.ALPHAT = simout.Data(:,6);
simulator.dPSI = simout.Data(:,7);
simulator.dPHI = simout.Data(:,8);

g = VehicleDynamicsLateral.Graphics(simulator);
g.TractorColor = 'r';

g.Frame();

%%
% <<../illustrations/frame/TemplateArticulatedSimulinkFrame.png>>
%

g.Animation();

%%
% As expected the vehicle starts traveling in a straight line and starts a turn at \(t = 1 \, s\) because of the step function.
%
% <<../illustrations/AnimationTemplateArticulatedSimulink.gif>>
%
##### SOURCE END #####
-->
</body>
</html>
